import unittest  # 导入测试框架

from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait  # 导入显式等待类
from selenium.webdriver.support import expected_conditions  # 导入等待条件
from selenium.webdriver.common.action_chains import ActionChains


class ZHYtest(unittest.TestCase):

    # 测试前：前置条件
    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.wait = WebDriverWait(self.driver,30)
        self.driver.get('http://localhost/cloud/#/recruit/addRecruit')

    def test(self) -> None:

        self.wait.until(expected_conditions.visibility_of_element_located
                        ((By.XPATH,'//*[@id="root"]/section/aside/div/ul/li[1]/div')))
        self.driver.find_element(By.XPATH,'//*[@id="root"]/section/aside/div/ul/li[1]/div').click()

        self.wait.until(expected_conditions.visibility_of_element_located
                        ((By.XPATH,'//*[@id="sale$Menu"]/li[5]/a')))
        self.driver.find_element(By.XPATH,'//*[@id="sale$Menu"]/li[5]/a').click()

        self.driver.find_element(By.XPATH,'//*[@id="root"]/section/section/main/div/div[1]/button[2]').click()
        time.sleep(5)




    # 测试后：清理测试环境
    def tearDown(self) -> None:
            self.driver.quit()